﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using BuXiaChu.OrderDishes.Model;
using BuXiaChu.OrderDishes.BLL;
using Microsoft.International.Converters.PinYinConverter;
using System.Text.RegularExpressions;

namespace BuXiaChu.OrderDishes.Web.Admin.Modules.Sys
{
    public partial class AddEmployeeToSysUser : System.Web.UI.UserControl
    {
        private Regex numReg = new Regex("\\d*", RegexOptions.IgnoreCase);
        public List<EmployeesModel> List
        {
            get;
            set;
        }

        public string AppHtmlSelect(int id)
        {
            List<ApplicationsModel> apps = ApplicationsManager.GetAll();

            var appsHtml = new StringBuilder();
            appsHtml.Append("<select id=\"sel_Website_" + id.ToString() + "\">");
            foreach (ApplicationsModel app in apps)
            {
                appsHtml.AppendFormat("<option value=\"{0}\">{1}</option>", app.ApplicationId, app.Name);
            }
            appsHtml.Append("</select>");

            return appsHtml.ToString();
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected string GetPinying(string chineseString)
        {
            var result = "";
            var pinYing = "";
            var firstChar = "";
            foreach (var ch in chineseString)
            {
                if (ChineseChar.IsValidChar(ch))
                {
                    ChineseChar chineseChar = new ChineseChar(ch);
                    if (chineseChar.PinyinCount > 0)
                    {
                        pinYing = numReg.Replace(chineseChar.Pinyins[0], "");
                        firstChar = pinYing[0].ToString();
                        pinYing = firstChar + pinYing.Substring(1).ToLower();
                        result += pinYing;
                    }
                }
            }

            return result;
        }
    }
}